<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>考试详情 - 在线考试系统</title>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/all.min.css">
    <style>
        :root {
            --primary: #4361ee;
            --primary-dark: #3a56d4;
            --secondary: #3f37c9;
            --accent: #4cc9f0;
            --light: #f8f9fa;
            --dark: #212529;
            --border: #e0e7ff;
            --success: #4caf50;
            --warning: #ff9800;
            --info: #2196f3;
            --card-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
        }
        
        body {
            background-color: #f5f7ff;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
            color: #333;
        }
        
        .navbar {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            box-shadow: 0 2px 10px rgba(67, 97, 238, 0.2);
            padding: 0.8rem 0;
        }
        
        .navbar-brand {
            font-weight: 700;
            font-size: 1.4rem;
        }
        
        .user-info {
            color: rgba(255,255,255,0.9);
            font-size: 0.95rem;
            margin-right: 15px;
        }
        
        .page-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 1.8rem;
            padding-bottom: 0.8rem;
            border-bottom: 1px solid var(--border);
        }
        
        .page-title {
            font-weight: 700;
            color: var(--dark);
            margin: 0;
            display: flex;
            align-items: center;
            font-size: 1.8rem;
        }
        
        .page-title i {
            margin-right: 12px;
            color: var(--primary);
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .exam-card {
            border-radius: 14px;
            box-shadow: var(--card-shadow);
            border: none;
            overflow: hidden;
            margin-bottom: 2.5rem;
        }
        
        .exam-header {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: #fff;
            padding: 1.5rem;
            border-radius: 14px 14px 0 0;
        }
        
        .exam-header h3 {
            font-weight: 700;
            margin-bottom: 0.8rem;
            display: flex;
            align-items: center;
        }
        
        .exam-header h3 i {
            margin-right: 12px;
            font-size: 1.5rem;
        }
        
        .exam-info {
            background: white;
            padding: 1.8rem;
        }
        
        .info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 1.5rem;
            margin-bottom: 1.5rem;
        }
        
        .info-item {
            background: #f9faff;
            border-radius: 10px;
            padding: 1.2rem;
            border-left: 4px solid var(--primary);
        }
        
        .info-label {
            font-weight: 600;
            color: #6c757d;
            margin-bottom: 0.3rem;
            font-size: 0.95rem;
        }
        
        .info-value {
            font-weight: 600;
            font-size: 1.1rem;
            color: var(--primary-dark);
        }
        
        .status-badge {
            display: inline-block;
            padding: 0.4rem 1.2rem;
            border-radius: 20px;
            font-weight: 600;
            font-size: 0.95rem;
        }
        
        .status-0 {
            background-color: #e0f7fa;
            color: #00838f;
            border: 1px solid #b2ebf2;
        }
        
        .status-1 {
            background-color: #e8f5e9;
            color: #388e3c;
            border: 1px solid #c8e6c9;
        }
        
        .status-2 {
            background-color: #ffebee;
            color: #c62828;
            border: 1px solid #ffcdd2;
        }
        
        .section-title {
            font-weight: 700;
            color: var(--primary-dark);
            margin: 1.8rem 0 1.2rem;
            padding-bottom: 0.5rem;
            border-bottom: 2px solid var(--border);
            display: flex;
            align-items: center;
        }
        
        .section-title i {
            margin-right: 10px;
            color: var(--primary);
        }
        
        .questions-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        }
        
        .questions-table th {
            background-color: #f0f4ff;
            font-weight: 600;
            color: var(--primary-dark);
            padding: 1.1rem 1.5rem;
            text-align: left;
            border-bottom: 2px solid var(--border);
        }
        
        .questions-table td {
            padding: 1.2rem 1.5rem;
            border-bottom: 1px solid var(--border);
            vertical-align: top;
        }
        
        .questions-table tr:nth-child(even) {
            background-color: #fafbff;
        }
        
        .questions-table tr:hover {
            background-color: #f0f5ff;
        }
        
        .question-type {
            display: inline-block;
            padding: 0.35rem 1rem;
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: 500;
            min-width: 70px;
            text-align: center;
        }
        
        .type-choice {
            background-color: #e3f2fd;
            color: #1976d2;
            border: 1px solid #bbdefb;
        }
        
        .type-multiple {
            background-color: #e8f5e9;
            color: #388e3c;
            border: 1px solid #c8e6c9;
        }
        
        .type-fill {
            background-color: #fff8e1;
            color: #ff8f00;
            border: 1px solid #ffecb3;
        }
        
        .type-essay {
            background-color: #f3e5f5;
            color: #7b1fa2;
            border: 1px solid #e1bee7;
        }
        
        .answer-cell {
            max-width: 250px;
            word-wrap: break-word;
        }
        
        .std-answer {
            background-color: #e8f5e9;
            padding: 0.5rem;
            border-radius: 6px;
            border: 1px solid #c8e6c9;
            color: #388e3c;
            font-weight: 500;
        }
        
        .student-answer {
            background-color: #e3f2fd;
            padding: 0.5rem;
            border-radius: 6px;
            border: 1px solid #bbdefb;
            color: #1976d2;
            font-weight: 500;
        }
        
        .score-cell {
            font-weight: 700;
            color: var(--primary-dark);
            font-size: 1.1rem;
        }
        
        .comment-cell {
            max-width: 300px;
            word-wrap: break-word;
            font-size: 0.95rem;
            color: #555;
        }
        
        .footer {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            padding: 2rem 0;
            margin-top: auto;
        }
        .student .footer {
            background: linear-gradient(135deg, var(--primary), #3a0ca3);
        }
        .copyright {
            text-align: center;
            padding-top: 1.5rem;
            margin-top: 1.5rem;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            color: rgba(255, 255, 255, 0.7);
            font-size: 0.9rem;
        }
        
        .not-found {
            text-align: center;
            padding: 3rem;
        }
        
        .not-found i {
            font-size: 4rem;
            color: #d0d9ff;
            margin-bottom: 1.5rem;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .not-found h4 {
            color: var(--primary-dark);
            margin-bottom: 0.8rem;
        }
        
        .not-found p {
            color: #6c757d;
            font-size: 1.05rem;
            max-width: 600px;
            margin: 0 auto 1.5rem;
        }
        
        .action-buttons {
            display: flex;
            gap: 12px;
            margin-top: 1.5rem;
        }
        
        .btn-outline-primary {
            border: 2px solid var(--primary);
            color: var(--primary);
            font-weight: 600;
            border-radius: 8px;
            padding: 0.6rem 1.5rem;
            transition: all 0.3s;
        }
        
        .btn-outline-primary:hover {
            background: var(--primary);
            color: white;
        }
        
        .btn-primary {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            border: none;
            font-weight: 600;
            border-radius: 8px;
            padding: 0.6rem 1.5rem;
            transition: all 0.3s;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(67, 97, 238, 0.4);
        }
        
        @media (max-width: 768px) {
            .info-grid {
                grid-template-columns: 1fr;
            }
            
            .page-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 1.2rem;
            }
            
            .questions-table {
                display: block;
                overflow-x: auto;
            }
            
            .page-title {
                font-size: 1.5rem;
            }
        }
    </style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark">
    <div class="container">
        <a class="navbar-brand" href="#">
            <i class="fas fa-graduation-cap"></i>在线考试系统
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav me-auto">
                <li class="nav-item">
                    <a class="nav-link" href="/home/manage"><i class="fas fa-home"></i> 主页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/student/exam/list"><i class="fas fa-pen-alt"></i> 考试信息</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/student/score/analysis"><i class="fas fa-chart-line"></i> 成绩分析</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/student/resources"><i class="fas fa-book-open"></i> 学习资源</a>
                </li>
            </ul>
            <ul class="navbar-nav ms-auto">
                <li class="nav-item">
                    <a class="nav-link" href="/student/profile/manage">
                        <i class="fas fa-user-circle"></i> 个人信息
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/logout">
                        <i class="fas fa-sign-out-alt"></i> 退出登录
                    </a>
                </li>
            </ul>
        </div>
    </div>
</nav>

<div class="container">
    <div class="page-header">
        <h1 class="page-title"><i class="fas fa-file-alt"></i>考试详情</h1>
        <div class="action-buttons">
            <button class="btn btn-primary" onclick="downloadPdf()"><i class="fas fa-download me-1"></i>导出PDF</button>
        </div>
    </div>
    
    <!-- 考试详情卡片 -->
    <div class="exam-card" th:if="${examDetail != null}">
        <div class="exam-header">
            <h3><i class="fas fa-file-signature"></i><span th:text="${examDetail.examName}">高等数学期末考试</span></h3>
            <div class="d-flex flex-wrap gap-2">
                <div class="status-badge status-0" th:if="${examDetail.status} == 0">未开始</div>
                <div class="status-badge status-1" th:if="${examDetail.status} == 1">进行中</div>
                <div class="status-badge status-2" th:if="${examDetail.status} == 2">已结束</div>
                <div class="text-white"><i class="fas fa-clock me-1"></i>时长: <span th:text="${examDetail.duration}"></span> 分钟</div>
                <div class="text-white"><i class="fas fa-star me-1"></i>总分: <span th:text="${examDetail.totalScore}"></span></div>
            </div>
        </div>
        
        <div class="exam-info">
            <div class="info-grid">
                <div class="info-item">
                    <div class="info-label">课程名称</div>
                    <div class="info-value" th:text="${examDetail.courseName}">高等数学</div>
                </div>
                <div class="info-item">
                    <div class="info-label">考试类型</div>
                    <div class="info-value" th:text="${examDetail.examType}">期末考试</div>
                </div>
                <div class="info-item">
                    <div class="info-label">授课教师</div>
                    <div class="info-value" th:text="${examDetail.teacherName}">李教授</div>
                </div>
                <div class="info-item">
                    <div class="info-label">所属班级</div>
                    <div class="info-value" th:text="${examDetail.className}">计算机科学与技术2023级1班</div>
                </div>
                <div class="info-item">
                    <div class="info-label">开始时间</div>
                    <div class="info-value" th:text="${#temporals.format(examDetail.startTime, 'yyyy-MM-dd HH:mm')}">2025-06-25 09:00</div>
                </div>
                <div class="info-item">
                    <div class="info-label">结束时间</div>
                    <div class="info-value" th:text="${#temporals.format(examDetail.endTime, 'yyyy-MM-dd HH:mm')}">2025-06-25 11:00</div>
                </div>
            </div>
            
            <h5 class="section-title"><i class="fas fa-list"></i>试题列表</h5>
            
            <div class="table-responsive">
                <table class="questions-table">
                    <thead>
                        <tr>
                            <th>题型</th>
                            <th>内容</th>
                            <th>分值</th>
                            <th>参考答案</th>
                            <th>我的作答</th>
                            <th>得分</th>
                            <th>教师评语</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr th:each="q : ${examDetail.questions}">
                            <td>
                                <span th:switch="${q.type}">
                                    <span class="question-type type-choice" th:case="'choice'">选择题</span>
                                    <span class="question-type type-multiple" th:case="'multiple'">多选题</span>
                                    <span class="question-type type-fill" th:case="'fill'">填空题</span>
                                    <span class="question-type type-essay" th:case="'essay'">简答题</span>
                                    <span class="question-type" th:case="*">未知类型</span>
                                </span>
                            </td>
                            <td th:text="${q.content}"></td>
                            <td class="score-cell" th:text="${q.score}"></td>
                            <td class="answer-cell">
                                <div class="std-answer" th:text="${q.stdAnswer}"></div>
                            </td>
                            <td class="answer-cell">
                                <div class="student-answer" th:text="${q.studentAnswer}"></div>
                            </td>
                            <td class="score-cell" th:text="${q.studentScore}"></td>
                            <td class="comment-cell" th:text="${q.teacher_comment}"></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    
    <!-- 未找到考试提示 -->
    <div class="exam-card" th:if="${examDetail == null}">
        <div class="not-found">
            <i class="fas fa-exclamation-triangle"></i>
            <h4>未找到考试详情</h4>
            <p>抱歉，无法找到您请求的考试信息，请检查考试ID是否正确或联系管理员</p>
            <button class="btn btn-primary" onclick="history.back()">
                <i class="fas fa-arrow-left me-1"></i>返回上一页
            </button>
        </div>
    </div>
    


</div>


<!-- 页脚 -->
<footer class="footer">
    <div class="container text-center py-4">
        <a href="https://gitee.com/sorrymaker04/onlineexam-workload" target="_blank"><i class="fab fa-github fa-2x"></i></a>
        <div class="copyright mt-2">
            &copy; 2025 版权所有 北城在线考试系统小组 12 Team
        </div>
    </div>
</footer>
<script src="/js/bootstrap.bundle.min.js"></script>
<script th:inline="javascript">
    function downloadPdf() {
        // recordId由后端传递到页面，通常在examDetail中
        var recordId = /*[[${examDetail['recordId']}]]*/ '';
        if (!recordId) {
            alert('未找到考试记录ID，无法导出PDF');
            return;
        }
        window.location.href = '/student/exam/pdf/export/' + recordId;
    }
</script>
</body>
</html>